package dhjang;


import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import javax.swing.JButton;
import javax.swing.BoxLayout;
import javax.swing.JTextField;
import java.awt.GridLayout;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JSlider;
import dhjang.gui.GUI_TextSlider_Float;

public class ParamFrame extends JFrame implements Observer{

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private GUI_TextSlider_Float m_FSlider_cooling = null;
	private GUI_TextSlider_Float m_FSlider_buyo_a = null;
	private GUI_TextSlider_Float m_FSlider_buyo_b = null;
	FluidSolverData fluidSolverData;  //  @jve:decl-index=0:
	/**
	 * This is the default constructor
	 */
	public ParamFrame() {
		super();
		initialize();
	}
	
	public float getCooling()
	{
		return m_FSlider_cooling.getFloatValue();
	}
	public float getBuyoA()
	{
		return m_FSlider_buyo_a.getFloatValue();
	}
	public float getBuyoB()
	{
		return m_FSlider_buyo_b.getFloatValue();
	}
	
	void updateTextFieldValue(JTextField field, float val)
	{
		field.setText(Float.toString(val));
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(298, 344);
		this.setContentPane(getJContentPane());
		this.setTitle("JFrame");
		
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			GridLayout gridLayout = new GridLayout();
			gridLayout.setRows(3);
			gridLayout.setHgap(10);
			gridLayout.setVgap(10);
			gridLayout.setColumns(1);
			jContentPane = new JPanel();
			jContentPane.setLayout(gridLayout);
			jContentPane.add(getM_FSlider_cooling(), null);
			jContentPane.add(getM_FSlider_buyo_a(), null);
			jContentPane.add(getM_FSlider_buyo_b(), null);
		}
		return jContentPane;
	}

	protected void updateSliderValue(JTextField source, JSlider jSlider) {
		float val = Float.valueOf(source.getText())*1000;
		
		if(jSlider.getMinimum() > val)
			jSlider.setMinimum((int)val);
		if(jSlider.getMaximum() < val)
			jSlider.setMaximum((int)val);
	}

	/**
	 * This method initializes m_FSlider_cooling	
	 * 	
	 * @return dhjang.gui.m_FSlider_coolingte 
	 */ 
	 GUI_TextSlider_Float getM_FSlider_cooling() {
		if (m_FSlider_cooling == null) {
			m_FSlider_cooling = new GUI_TextSlider_Float();
			m_FSlider_cooling.setFloatValue(0.1F);
		}
		return m_FSlider_cooling;
	}

	/**This method initializes m_FSlider_buyo_a	
	 * 	
	 * @return dhjang.gui.GUI_TextSlider_Float	
	 */
	private GUI_TextSlider_Float getM_FSlider_buyo_a() {
		if (m_FSlider_buyo_a == null) {
			m_FSlider_buyo_a = new GUI_TextSlider_Float();
			m_FSlider_buyo_a.setFloatValue(6.25E-4F);
			m_FSlider_buyo_a.setResolution(100000.0F);
		}
		return m_FSlider_buyo_a;
	}

	/**
	 * This method initializes m_FSlider_buyo_b	
	 * 	
	 * @return dhjang.gui.GUI_TextSlider_Float	
	 */
	private GUI_TextSlider_Float getM_FSlider_buyo_b() {
		if (m_FSlider_buyo_b == null) {
			m_FSlider_buyo_b = new GUI_TextSlider_Float();
			m_FSlider_buyo_b.setFloatValue(0.025F);
			m_FSlider_buyo_b.setResolution(10000.0F);
		}
		return m_FSlider_buyo_b;
	}

	public void setFluidData(FluidSolverData fluidSolverData) {
		// TODO Auto-generated method stub
		this.fluidSolverData = fluidSolverData;
	}

	@Override
	public void update(Observable o, Object arg) {
		fluidSolverData.setCooling_rate(getCooling());
		fluidSolverData.setBuoyancy_contant_a(getBuyoA());
		fluidSolverData.setBuoyancy_contant_b(getBuyoB());
		
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
